home *** CD-ROM | disk | FTP | other *** search
- // Copyright 1999 Macromedia, Inc. All rights reserved.
-
- //*************** GLOBALS VARS *****************
-
- var TAG_NAME = "{#CUSTOMOBJ}"
-
- var PAGE = '';
-
- var MAKE_BACKUP = true;
-
- var LOG_INFO = '';
- var HTML_START = '<html><head><title>%s</title></head><body>\n';
- var HTML_STOP = '</body></html>';
- var LOG_TITLE = '<center><tt><font size=5><b>%s</b></font><br>%s</tt></center>\n<br><br>\n';
- var SECTION_START = '<tt><font size=4><b>%s</b></font></tt><br><ul>\n';
- var SECTION_STOP = '</ul>\n';
- var SECTION_ITEM = '<li>%s</li>\n';
- var SECTION_ITEM_ERROR = '<br><font color="red">%s</font>\n';
- var HTML_ERROR = '<font color="red">%s</font>';
- var ERRORS = 0;
-
- var DOM_OBJ = '';
-
- //******************* API **********************
-
- function canAcceptCommand() {
- if (documentSaved(true)) return true;
- else return false;
- }
-
- //***************** LOCAL FUNCTIONS ******************
-
-
- //Convert From Previous Versions
- //
- function convert() {
- DOM_OBJ = dreamweaver.getDocumentDOM();
-
- convertCustomObjects();
-
- addSection(MSG_secDocConvert);
-
- convertAttainObjIds();
- convertAttainKos();
- convertFns();
- convertWriteToFns();
- convertTemplateRefs();
- convertQuotes();
- // convertGizmos();
- updatePage();
-
- endSection();
- }
-
-
- //Convert from custom objects
- //
- function convertCustomObjects() {
- var customList, i, obj, objSrc, intId, name;
- var intList, includeSrc, scriptList, script, source, am;
- var iSrcList, divList, divObj, index;
-
- var DOM_OBJ = dreamweaver.getDocumentDOM();
-
- customList = DOM_OBJ.getElementsByTagName(TAG_NAME);
-
- if (customList.length > 0) {
-
- addSection(MSG_secConvertTags);
-
- for (var i=0; i < customList.size; i++) {
- obj = customList.item(i);
- name = obj.getAttribute("NAME");
-
- addItem(MSG_itemConverting + name);
-
- objSrc = obj.outerHTML;
- intId = objSrc.match(/KO_int\s*\(\s*['"](K\d\d)['"]/);
- if (intId != null)
- intId = intId[1];
- else {
- addError(MSG_intIdNotFound, true);
- continue;
- }
-
- // move behavior information outside of the KO
- var behInfo = '', result;
- var behCall = /<!--\s*#BeginBehavior\s+(\w+)\s*-->[^\x00]*<!--\s*#EndBehavior\s+(\1)\s*-->/;
- while ((result = behCall.exec(objSrc)) != null) {
- behInfo += result[0];
- objSrc = objSrc.substring(0, result.index) + objSrc.substring(result.index + result[0].length);
- }
-
- // replace the custom object tags
- objSrc = objSrc.replace(/<!--\s*#BeginCustomObject/, "<interaction object=\""+intId+"\"");
- objSrc = objSrc.replace(/\s*-->/, ">");
- objSrc = objSrc.replace(/<!--\s*#EndCustomObject\s*-->/,"<cbi-select object=\""+intId+"\"></interaction>");
- obj.outerHTML = NEWLINE + objSrc + NEWLINE + behInfo + NEWLINE;
- }
-
- endSection();
-
- // now find all the Interaction objects, and continue the conversion
-
- intList = DOM_OBJ.getElementsByTagName("INTERACTION");
- for (i=0; i < intList.size; i++) {
- obj = intList.item(i);
- intId = obj.getAttribute(OBJID_ATTR);
- name = obj.getAttribute(NAME_ATTR);
-
- addSection(MSG_secUpdating + name);
-
- // Remove the wizard and type attributes
- addItem(MSG_itemDelAttrs);
- obj.removeAttribute("wizard");
- obj.removeAttribute("type");
-
- // Remove script includes, creating an include source list
- addItem(MSG_itemScripts);
- includeSrc = '';
- scriptList = obj.getElementsByTagName("SCRIPT");
- for (var j=0; j < scriptList.size; j++) {
- script = scriptList.item(j);
- if (script.getAttribute("src") != null) { //convert include
- source = script.getAttribute("src");
- if (script.innerHTML.indexOf('if') == -1) { //add it to includeSrc
- source = source.substring(source.lastIndexOf('/')+1);
- includeSrc += ((includeSrc.length == 0)?'':',') + source;
- }
- script.outerHTML = ''; //remove the include
- } else if (script.innerHTML.indexOf("KO_int(") != -1) { //update init code
- addItem(MSG_itemAMConvert);
- script.setAttribute("object", intId);
- // remove init stuff
- am = script.innerHTML;
- am = am.replace(/\s*with\s+\(navigator\)(.|\n)*\/\/-->/, '\n//-->');
- script.innerHTML = am;
- } else if (script.getAttribute("name") == "cmifrag") {
- script.outerHTML = ''; // remove the CMI init code
- } }
- obj.setAttribute(INC_SRC_ATTR, includeSrc);
-
- // Add a <div> tag around the HTML portion of the KO
- // This should not include any existing layers.
- // This tag will be used to insert the KO in a layer.
- addItem(MSG_itemAddDiv);
- objSrc = obj.innerHTML;
- var index = objSrc.search(/\<script[^>]*object=["']K\d\d["']/i);
- if (index != -1) {
- obj.innerHTML = "<div name=\""+ intId +"Layer\">" + NEWLINE +
- objSrc.substring(0, index) +
- "</div>" + NEWLINE +
- objSrc.substring(index);
- divList = obj.getElementsByTagName("DIV");
- // find the new div
- for (var j=0; j < divList.size; j++) {
- if (divList.item(j).getAttribute("name") == intId + "Layer") {
- divObj = divList.item(j);
- break;
- } }
- // now move non-nested layers outside the new div
- divList = divObj.getElementsByTagName("DIV");
- var divHTML = '';
- for (var j=0; j < divList.size; j++) {
- if (isLayer(divList.item(j))) {
- var parent = divList.item(j);
- while (parent.parentNode != divObj && parent != null)
- parent = parent.parentNode;
- if (parent == null) parent = divList.item(j);
- divHTML += parent.outerHTML;
- parent.outerHTML = '';
- divList = divObj.getElementsByTagName("DIV");
- j--;
- } }
- if (divHTML) divObj.outerHTML = divObj.outerHTML + divHTML;
- }
-
- endSection();
- } }
- }
-
-
- //Convert Kxx to Gxx. Convert KO_int to AttainObj. Convert Gizmo to AttainObj.
- //
- function convertAttainObjIds() {
- var docSrc;
- addItem(MSG_itemConvertIds);
- docSrc = DOM_OBJ.documentElement.innerHTML;
- docSrc = docSrc.replace(/new KO_int/g, "new MM_interaction");
- docSrc = docSrc.replace(/new AttainObj/g, "new MM_interaction");
- docSrc = docSrc.replace(/K(\d\d)/g, "G$1");
- if (DOM_OBJ.documentElement.innerHTML != docSrc)
- DOM_OBJ.documentElement.innerHTML = docSrc;
- }
-
-
- //Convert <attain-ko>, <attain-select>, <attain-object> and <attain-am> tags to
- // <interaction> and <cbi-select>.
- //
- function convertAttainKos() {
- var bodySrc, amList, i, obj, attainObjId;
- addItem(MSG_itemConvertTags);
- bodySrc = DOM_OBJ.body.outerHTML;
- bodySrc = bodySrc.replace(/attain-ko/gi, "interaction");
- bodySrc = bodySrc.replace(/attain-object/gi, "interaction");
- bodySrc = bodySrc.replace(/attain-select/gi, "cbi-select");
- if (DOM_OBJ.body.outerHTML != bodySrc)
- DOM_OBJ.body.outerHTML = bodySrc;
-
- // Convert beta <attain-am> tags to <cbi-select> tags
- amList = DOM_OBJ.getElementsByTagName("ATTAIN-AM");
- if (amList.length > 0) {
- addItem(MSG_itemAddSelectIcon);
- for (i=0; i < amList.size; i++) {
- obj = amList.item(i);
- attainObjId = obj.getAttribute(OBJID_ATTR);
- obj.outerHTML = obj.innerHTML + NEWLINE + "<cbi-select object=\""+attainObjId+"\">";
- } }
- }
-
-
- //Convert behavior calls and js includes.
- //
- function convertFns() {
- var docSrc;
-
- addItem(MSG_itemConvertFunctions);
-
- // remove any existing function declarations
- PAGE.scriptDOM.removeFunction("MM_initKO");
- PAGE.scriptDOM.removeFunction("MM_judgeKO");
- PAGE.scriptDOM.removeFunction("MM_resetKO");
- PAGE.scriptDOM.removeFunction("MM_setKOProperties");
-
- PAGE.scriptDOM.removeFunction("MM_initAttainObj");
- PAGE.scriptDOM.removeFunction("MM_judgeAttainObj");
- PAGE.scriptDOM.removeFunction("MM_resetAttainObj");
- PAGE.scriptDOM.removeFunction("MM_setAttainObjProps");
-
- // now change the function and include names
- docSrc = DOM_OBJ.documentElement.innerHTML;
- docSrc = docSrc.replace(/behKnowledgeActions\.js/g, "behCourseBuilder.js");
- docSrc = docSrc.replace(/intClass\.js/g, "interactionClass.js");
- docSrc = docSrc.replace(/MM_initKO\(/g, "MM_initInteractions(");
- docSrc = docSrc.replace(/MM_judgeKO\(/g, "MM_judgeInt(");
- docSrc = docSrc.replace(/MM_resetKO\(/g, "MM_resetInt(");
- docSrc = docSrc.replace(/MM_setKOProperties\(/g, "MM_setIntProps(");
- docSrc = docSrc.replace(/initKoFns/g, "MM_initIntFns");
-
- docSrc = docSrc.replace(/behAttainObjects\.js/g, "behCourseBuilder.js");
- docSrc = docSrc.replace(/attainObjClass\.js/g, "interactionClass.js");
- docSrc = docSrc.replace(/MM_initAttainObj\(/g, "MM_initInteractions(");
- docSrc = docSrc.replace(/MM_judgeAttainObj\(/g, "MM_judgeInt(");
- docSrc = docSrc.replace(/MM_resetAttainObj\(/g, "MM_resetInt(");
- docSrc = docSrc.replace(/MM_setAttainObjProps\(/g, "MM_setIntProps(");
- docSrc = docSrc.replace(/initAttainObjFns/g, "MM_initIntFns");
-
- docSrc = docSrc.replace(/KO_findObject\(/g, "MM_intFindObject(");
- docSrc = docSrc.replace(/KO_getDocProp\(/g, "MM_getDocProp(");
- docSrc = docSrc.replace(/KA_preloadImages/g, "MM_preloadImages");
-
- docSrc = docSrc.replace(/AO_findObject\(/g, "MM_intFindObject(");
- docSrc = docSrc.replace(/AO_getDocProp\(/g, "MM_getDocProp(");
-
- // change the nice names in the action manager
- docSrc = docSrc.replace(/(['"]actn['"]\s*,\s*['"])Judge(["':])/g, "$1Judge Interaction$2");
- docSrc = docSrc.replace(/(['"]actn['"]\s*,\s*['"])Reset(["':])/g, "$1Reset Interaction$2");
- docSrc = docSrc.replace(/(['"]actn['"]\s*,\s*['"])Set Properties(["':])/g, "$1Set Interaction Properties$2");
-
- docSrc = docSrc.replace(/(['"]actn['"]\s*,\s*['"])Control Sound(["':])/g, "$1Play Sound$2");
- docSrc = docSrc.replace(/(['"]actn['"]\s*,\s*['"])Judge Attain Object(["':])/g, "$1Judge Interaction$2");
- docSrc = docSrc.replace(/(['"]actn['"]\s*,\s*['"])Reset Attain Object(["':])/g, "$1Reset Interaction$2");
- docSrc = docSrc.replace(/(['"]actn['"]\s*,\s*['"])Set Attain Properties(["':])/g, "$1Set Interaction Properties$2");
-
-
- if (DOM_OBJ.documentElement.innerHTML != docSrc)
- DOM_OBJ.documentElement.innerHTML = docSrc;
- }
-
-
- //Convert Write To Behaviors to Set Text
- //
- function convertWriteToFns() {
- var docSrc;
-
- addItem(MSG_itemConvertWriteToFns);
-
- // remove any existing function declarations
- PAGE.scriptDOM.removeFunction("MM_replaceLayerText");
- PAGE.scriptDOM.removeFunction("MM_writeToLayer");
- PAGE.scriptDOM.removeFunction("MM_writeToFrame");
- PAGE.scriptDOM.removeFunction("MM_writeToPopup");
- PAGE.scriptDOM.removeFunction("MM_writeToTextfield");
-
- // now change the function and include names
- docSrc = DOM_OBJ.documentElement.innerHTML;
- docSrc = docSrc.replace(/MM_replaceLayerText\(/g, "MM_setTextOfLayer(");
- docSrc = docSrc.replace(/MM_writeToLayer\(/g, "MM_setTextOfLayer(");
- docSrc = docSrc.replace(/MM_writeToFrame\(/g, "MM_setTextOfFrame(");
- docSrc = docSrc.replace(/MM_writeToPopup\(/g, "MM_popupMsg(");
- docSrc = docSrc.replace(/MM_writeToTextfield\(/g, "MM_setTextOfTextfield(");
-
- // change the nice names in the action manager
- docSrc = docSrc.replace(/(['"]actn['"]\s*,\s*['"])Replace Layer Text(["':])/g, "$1Set Text of Layer$2");
- docSrc = docSrc.replace(/(['"]actn['"]\s*,\s*['"])Write To Popup(["':])/g, "$1Popup Message$2");
- docSrc = docSrc.replace(/(['"]actn['"]\s*,\s*['"])Write To Layer(["':])/g, "$1Set Text of Layer$2");
- docSrc = docSrc.replace(/(['"]actn['"]\s*,\s*['"])Write To Frame(["':])/g, "$1Set Text of Frame$2");
- docSrc = docSrc.replace(/(['"]actn['"]\s*,\s*['"])Write To Text Field(["':])/g, "$1Set Text of Text Field$2");
- docSrc = docSrc.replace(/(['"]actn['"]\s*,\s*['"])Display Status Message(["':])/g, "$1Set Text of Status Bar$2");
-
- if (DOM_OBJ.documentElement.innerHTML != docSrc)
- DOM_OBJ.documentElement.innerHTML = docSrc;
- }
-
-
- function convertTemplateRefs() {
- var bodySrc;
- addItem(MSG_itemConvertTemplates);
- bodySrc = DOM_OBJ.body.outerHTML;
- bodySrc = bodySrc.replace(/\.kot/g, ".agt");
- if (DOM_OBJ.body.outerHTML != bodySrc)
- DOM_OBJ.body.outerHTML = bodySrc;
- }
-
-
- //Convert from double to single quotes in the action manager
- //
- function convertQuotes() {
- var scriptList, i, j, obj, objSrc, newSrc, lastIndex, inString;
- scriptList = DOM_OBJ.getElementsByTagName("SCRIPT");
- if (scriptList.length > 0) {
- addItem(MSG_convertQuotes);
- for (i=0; i < scriptList.size; i++) {
- obj = scriptList.item(i);
- if (obj.getAttribute("SRC") == null &&
- obj.innerHTML.indexOf("MM_interaction") != -1 &&
- obj.innerHTML.search(/function\s+newG\d\d\s*\(/) != -1) {
- objSrc = obj.innerHTML;
- inString = false; lastIndex = 0; newSrc = '';
- for (j=0; j < objSrc.length; j++) {
- if (objSrc.charAt(j) == '"' && (j == 0 || objSrc.charAt(j-1) != '\\')) {
- inString = !inString;
- newSrc += objSrc.substring(lastIndex, j) + "'";
- lastIndex = j+1;
- }
- if (inString && objSrc.charAt(j) == "'" && objSrc.charAt(j-1) != '\\') {
- newSrc += objSrc.substring(lastIndex, j) + "\\'";
- lastIndex = j+1;
- }
- }
- if (lastIndex != 0) {
- newSrc += objSrc.substring(lastIndex);
- if (newSrc != obj.innerHTML)
- obj.innerHTML = newSrc;
- } } } }
- }
-
-
- /*
- //Convert <gizmo> to <attain-object>, <gizmo-select> to <attain-selelct>, etc.
- //
- function convertGizmos() {
- var bodySrc, amList, i, obj, attainObjId;
- addItem(MSG_itemConvertTags);
- bodySrc = DOM_OBJ.body.outerHTML;
- bodySrc = bodySrc.replace(/new Gizmo/g, "new AttainObj");
- bodySrc = bodySrc.replace(/<gizmo-select/gi, "<attain-select");
- bodySrc = bodySrc.replace(/<gizmo/gi, "<attain-object");
- bodySrc = bodySrc.replace(/<\/gizmo/gi, "</attain-object");
- if (DOM_OBJ.body.outerHTML != bodySrc)
- DOM_OBJ.body.outerHTML = bodySrc;
-
- // now change the function and include names
- docSrc = DOM_OBJ.documentElement.innerHTML;
- docSrc = docSrc.replace(/behAttainGizmos\.js/g, "behAttainObjects.js");
- docSrc = docSrc.replace(/gizmoClass\.js/g, "attainObjClass.js");
- docSrc = docSrc.replace(/MM_initGizmo\(/g, "MM_initAttainObj(");
- docSrc = docSrc.replace(/MM_judgeGizmo\(/g, "MM_judgeAttainObj(");
- docSrc = docSrc.replace(/MM_resetGizmo\(/g, "MM_resetAttainObj(");
- docSrc = docSrc.replace(/MM_setGizmoProperties\(/g, "MM_setAttainObjProps(");
- docSrc = docSrc.replace(/initGizmoFns/g, "initAttainObjFns");
- docSrc = docSrc.replace(/AG_findObject\(/g, "AO_findObject(");
- docSrc = docSrc.replace(/AG_getDocProp\(/g, "AO_getDocProp(");
-
- // change the nice names in the action manager
- docSrc = docSrc.replace(/(['"]actn['"]\s*,\s*['"])Reset Gizmo(["':])/g, "$1Reset Attain Object$2");
- docSrc = docSrc.replace(/(['"]actn['"]\s*,\s*['"])Judge Gizmo(["':])/g, "$1Judge Attain Object$2");
- docSrc = docSrc.replace(/(['"]actn['"]\s*,\s*['"])Set Gizmo Properties(["':])/g, "$1Set Attain Properties$2");
- docSrc = docSrc.replace(/Disable Gizmo/g, "Disable Object");
-
- if (DOM_OBJ.documentElement.innerHTML != docSrc)
- DOM_OBJ.documentElement.innerHTML = docSrc;
- }
- */
-
-
- function updatePage() {
- // Add initialization functions and events
- addItem(MSG_itemAddInit);
- PAGE.updateAttainObjInit();
-
- addItem(MSG_itemAddBeh);
- PAGE.insertBehaviorFns(DOM_OBJ.body.outerHTML);
-
- // Add script includes to the head of the document
- addItem(MSG_itemAddScripts);
- PAGE.insertAttainObjIncludes();
- PAGE.updateCmiIncludes();
-
- // Remove any functions which are now part of the includes
- addItem(MSG_itemRemoveFns);
- PAGE.removeRedundantFns();
- PAGE.removeEmptyAttainObjs();
- }
-
- function initializeUI() {
- var obj, theSel, intId = '', oldFile;
- var docDOM = dw.getDocumentDOM();
- var stopConvert = false;
-
- if (!regCheck()) {
- window.close();
- return;
- }
-
-
- setBusyCursor();
-
- setNewline(); //init NEWLINE global
-
- // create the page object
- PAGE = new AttainDOM();
-
- startLog(LABEL_convertLog, LABEL_convertLog, dreamweaver.getDocumentPath("document"));
-
- // check that the scripts exist
- if (needToCopySupportFiles()) {
- if (confirm(MSG_overwriteFiles)) {
- copySupportFiles(false, true, true);
- if (needToCopySupportFiles()) {
- alert(MSG_scriptsNotUpdated);
- stopConvert = true;
- } else {
- addHtml(MSG_copiedSupportFiles + "<br><br>");
- }
- } else {
- addHtml(MSG_supportFilesNotCopied + "<br><br>");
- }
- } else {
- addHtml(MSG_supportFilesCurrent + "<br><br>");
- }
-
- // remove uneeded script files: intClass.js, behKnowledgeActions.js
- if (!stopConvert) {
- oldFile = new File(PREF_scriptsUrl + File.separator + "intClass.js");
- if (oldFile.exists() && !oldFile.remove())
- addHtmlError(errMsg(MSG_fileNotRemoved, oldFile.getAbsolutePath()) + "<br><br>");
- oldFile = new File(PREF_scriptsUrl + File.separator + "behKnowledgeActions.js");
- if (oldFile.exists() && !oldFile.remove())
- addHtmlError(errMsg(MSG_fileNotRemoved, oldFile.getAbsolutePath()) + "<br><br>");
-
- oldFile = new File(PREF_scriptsUrl + File.separator + "attainObjClass.js");
- if (oldFile.exists() && !oldFile.remove())
- addHtmlError(errMsg(MSG_fileNotRemoved, oldFile.getAbsolutePath()) + "<br><br>");
- oldFile = new File(PREF_scriptsUrl + File.separator + "behAttainObjects.js");
- if (oldFile.exists() && !oldFile.remove())
- addHtmlError(errMsg(MSG_fileNotRemoved, oldFile.getAbsolutePath()) + "<br><br>");
- }
-
- // create a backup
- if (!stopConvert && MAKE_BACKUP) {
- if (!createBackup()) {
- if (!confirm(MSG_unableToMakeBackup))
- stopConvert = true;
- else
- addHtml(MSG_backupNotCreated + "<br><br>");
- } else
- addHtml(MSG_createdBackup + dreamweaver.getDocumentPath("document")+".bak<br><br>");
- }
-
- if (!stopConvert) {
-
- addHtml(MSG_updatingFile + dreamweaver.getDocumentPath("document") + "<br><br>");
-
- // Get the currently selected custom obj id
- obj = getCustomObj();
- if (obj) {
- intId = obj.outerHTML.match(/KO_int\s*\(\s*['"]K(\d\d)['"]/);
- if (intId != null) intId = "G" + intId[1];
- } else {
- obj = getOldAttainObj();
- if (obj) {
- intId = obj.outerHTML.match(/KO_int\s*\(\s*['"]K(\d\d)['"]/);
- if (intId != null) {
- intId = "G" + intId[1];
- } else {
- intId = obj.getAttribute(OBJID_ATTR);
- } } }
-
-
- convert();
-
- addHtml("<br><br>" + MSG_convertDone);
-
- saveLog();
-
- // Re-select the original custom object, if it exists
- if (intId) {
- obj = getAttainObj(intId);
- theSel = docDOM.nodeToOffsets(obj);
- docDOM.setSelection(theSel[0], theSel[1]);
- } else {
- docDOM.setSelection(0,0);
- }
-
- }
-
- garbageCollect(false);
- clearBusyCursor();
- window.close();
-
- if (!stopConvert) {
- // Indicate results
- var message = (ERRORS) ? MSG_errorsGenerated : MSG_success;
- if (confirmCustom(message, LABEL_ok, LABEL_viewLog) == LABEL_viewLog)
- dreamweaver.browseDocument(FILE_convertLog);
- }
-
- window.close(); // DW BUG: call again to prevent hang
- }
-
-
- //Creates a backup file of the current document
- // Return true if successful
- //
- function createBackup() {
- var docSrc, fileName, file, result;
- var retVal = false;
-
- docSrc = dreamweaver.getDocumentDOM().documentElement.outerHTML;
- fileName = dreamweaver.getDocumentPath("document") + ".bak";
-
- file = new File(fileName);
- if (file.exists()) {
- result = file.remove();
- if (!result) return retVal;
- }
-
- result = file.setContents(docSrc);
- if (result) retVal = true;
-
- return retVal;
- }
-
-
- //Returns the currently selected custom object, or null if it
- // does not exist.
- //
- function getCustomObj() {
- var theSel, theObj;
- var docDOM = dw.getDocumentDOM();
- theSel = docDOM.getSelection();
- theObj = docDOM.offsetsToNode(theSel[0],theSel[1]);
- while (theObj != null) {
- if (theObj.nodeType == Node.ELEMENT &&
- theObj.tagName == "{#CUSTOMOBJ}" &&
- theObj.getAttribute("wizard") == "Knowledge Object")
- break;
- theObj = theObj.parentNode;
- }
- if (theObj)
- return theObj;
- else
- return null;
- }
-
-
- //Returns the currently selected custom object, or null if it
- // does not exist.
- //
- function getOldAttainObj() {
- var theSel, theObj;
- var docDOM = dw.getDocumentDOM();
- theSel = docDOM.getSelection();
- theObj = docDOM.offsetsToNode(theSel[0],theSel[1]);
- while (theObj != null) {
- if (theObj.nodeType == Node.ELEMENT &&
- (theObj.tagName == "ATTAIN-KO" ||
- theObj.tagName == "ATTAIN-OBJECT") )
- break;
- theObj = theObj.parentNode;
- }
- if (theObj)
- return theObj;
- else
- return null;
- }
-
-
- function startLog(title, header, filePath) {
- var date = new Date;
- var file = new File(filePath);
- LOG_INFO = errMsg(HTML_START, title + LABEL_logSeparator + file.getName());
- LOG_INFO += errMsg(LOG_TITLE, header, date);
- }
-
- function addHtml(message) {
- LOG_INFO += message;
- }
-
- function addHtmlError(message) {
- LOG_INFO += errMsg(HTML_ERROR, message);
- ERRORS++;
- }
-
- function addSection(name) {
- LOG_INFO += errMsg(SECTION_START, name);
- saveLog();
- }
-
- function addItem(message) {
- LOG_INFO += errMsg(SECTION_ITEM, message);
- saveLog();
- }
-
- function addError(message) {
- LOG_INFO += errMsg(SECTION_ITEM_ERROR, message);
- ERRORS++;
- saveLog
- }
-
- function endSection() {
- LOG_INFO += SECTION_STOP;
- saveLog();
- }
-
- function saveLog() {
- var file = new File(FILE_convertLog);
- file.setContents(LOG_INFO + HTML_STOP);
- }
-
-